package com.aaa.day118.demo2;

/**
 * @Description:
 * @author:LiWei
 * @date:2022年11月08日16:26
 */
public class Test {
    public static void main(String[] args) {
        HuaWei huaWei=HuaWeiFactory.createHuaWei("1");
        huaWei.move();

    }
}

abstract class HuaWei {
    public abstract void move();
}

class Huawei1 extends HuaWei{
    @Override
    public void move() {
        System.out.println("华为1");
    }
}

class HuaWei2 extends HuaWei {
    @Override
    public void move() {
        System.out.println("华为2");
    }
}

class HuaWeiFactory {

    public static HuaWei createHuaWei(String type){
        if(type.equals("1")){
            return new Huawei1();
        }else if(type.equals("2")){
            return new HuaWei2();
        }else{
            return null;
        }
    }
}

